package cn.wolfcode.common.utils;

import cn.wolfcode.common.exception.BusinessException;
import cn.wolfcode.common.web.CodeMsg;
import cn.wolfcode.common.web.Result;

public class AssertUtil {

    public static void notNull(Object obj, String msg) {
        if (obj == null) {
            throw new BusinessException(new CodeMsg(Result.FAIL_CODE, msg));
        }
    }

    public static void isTrue(Boolean ret, String msg) {
        if(!ret){
            throw new BusinessException(new CodeMsg(Result.FAIL_CODE,msg));
        }
    }
    public static void isTrue(Boolean ret,  CodeMsg codeMsg) {
        if(!ret){
            throw new BusinessException(codeMsg);
        }
    }

    public static void isFalse(Boolean ret, String msg) {
        if(ret){
            throw new BusinessException(new CodeMsg(Result.FAIL_CODE,msg));
        }
    }

    public static void isFalse(Boolean ret, CodeMsg codeMsg) {
        if(ret){
            throw new BusinessException(codeMsg);
        }
    }
}
